<!DOCTYPE HTML>
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:include="public/layout::header('添加菜单')" th:remove="tag"></div>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" method="post" action="" id="form-admin-add">
        <input type="hidden" th:if="${pmenu} != null"  name="pId" th:value="${pmenu} != null?${pmenu.id}:'0'"/>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>上一级：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span th:text="${pmenu}!=null?${pmenu.name}:'顶级菜单'"></span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="name" name="name"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>链接：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="uri" name="uri"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-number" value="100" placeholder="" id="order" name="order" />
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="note" cols="" rows="" class="textarea"  placeholder="说点什么...100个字符以内" dragonfly="true" onKeyUp="$.Huitextarealength(this,100)"></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
            </div>
        </div>
    </form>
</article>
<!--_footer 作为公共模版分离出去-->
<div th:include="public/layout::footer" th:remove="tag"></div>
<!--/_footer 作为公共模版分离出去-->


<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").validate({
            rules:{
                name:{
                    required:true,
                    minlength:1,
                    maxlength:16
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    url: $(form).attr("action") ,
                    dataType:'json',
                    success: function(data){
                        console.log(data);
                        if(data.code==0){
                            layer.msg(data.msg,{icon:1,time:3000},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);

                            });
                        }else {
                            layer.msg(data.msg,{icon:1,time:3000});
                        }


                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('网络请求失败，请检查!',{icon:1,time:3000});
                    }
                });


            }
        });
    });
</script>

</body>
</html>